package cn.iocoder.yudao.module.system.dal.mysql.worksaleoutbound;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.dal.dataobject.workorder.WorkOrderDO;
import cn.iocoder.yudao.module.system.dal.dataobject.worksaleoutbound.WorkSaleOutboundDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.system.controller.admin.worksaleoutbound.vo.*;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Value;

/**
 * 销售出库 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface WorkSaleOutboundMapper extends BaseMapperX<WorkSaleOutboundDO> {

    default PageResult<WorkSaleOutboundDO> selectPage(WorkSaleOutboundPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<WorkSaleOutboundDO>()
                .leIfPresent(WorkSaleOutboundDO::getCreateTime, reqVO.getCreateTimeEnd())
                .geIfPresent(WorkSaleOutboundDO::getCreateTime, reqVO.getCreateTimeStart())
                .eqIfPresent(WorkSaleOutboundDO::getOutboubdType, reqVO.getOutboubdType())
                .eqIfPresent(WorkSaleOutboundDO::getWorkId, reqVO.getWorkId())
                .eqIfPresent(WorkSaleOutboundDO::getBatchNumber, reqVO.getBatchNumber())
                .eqIfPresent(WorkSaleOutboundDO::getOutboundQuantity, reqVO.getOutboundQuantity())
                .eqIfPresent(WorkSaleOutboundDO::getOutboundWeight, reqVO.getOutboundWeight())
                .eqIfPresent(WorkSaleOutboundDO::getUnitPrice, reqVO.getUnitPrice())
                .betweenIfPresent(WorkSaleOutboundDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(WorkSaleOutboundDO::getId));
    }
    @Select("select count(1) from system_work_sale_outbound where  work_id=#{workId}")
    Long selectCount2(Integer workId,String batchNumber,String date);
}
